import { shuffle, uniqueId } from 'lodash-es'

export interface IIconCard {
  icon: string | number
  matched?: boolean
}

export function getIcons(num: number): Array<IIconCard & { id: string }> {
  const icons = [
    'fire',
    'like',
    'diamond',
    'gift',
    'bell',
    'audio',
    'live',
    'cart'
  ]
  const result = shuffle(icons).slice(0, num / 2)
  return shuffle(result.concat(result)).map(icon => ({
    icon,
    id: uniqueId('icon_'),
    matched: undefined
  }))
}

export type INumberCard = Omit<IIconCard, 'icon'> & { id: string; icon: number }

export function getNumbers(num: number): Array<INumberCard> {
  const numList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
  const result = numList.slice(0, num)
  return shuffle(result).map(icon => ({
    icon,
    id: uniqueId('num_'),
    matched: undefined
  }))
}
